package org.sdp.pearproject.controller;


import org.sdp.pearproject.controller.custom.*;
import org.sdp.pearproject.dto.request.*;
import org.sdp.pearproject.dto.response.*;

import java.util.List;

import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @ClassName: EventsController
 * @Description:
 * @Author: SDP
 * @Date: 2022-07-27
 * @Version: 1.0
 * Table: pear_events
 * Comment:
 * 日程表
 */
@RestController
@RequestMapping(value = "/events")
public class EventsController extends EventsCustomController {
    static {
        addRequestClass("events", "add", "eventsController", EventsController.class, EventsAddRequest.class);
        addRequestClass("events", "add_encrypt", "eventsController", EventsController.class, EventsAddRequest.class);

        addRequestClass("events", "update", "eventsController", EventsController.class, EventsUpdateRequest.class);
        addRequestClass("events", "update_encrypt", "eventsController", EventsController.class, EventsUpdateRequest.class);

        addRequestClass("events", "delete", "eventsController", EventsController.class, EventsDeleteRequest.class);
        addRequestClass("events", "delete_encrypt", "eventsController", EventsController.class, EventsDeleteRequest.class);

        addRequestClass("events", "query", "eventsController", EventsController.class, EventsQueryRequest.class);
        addRequestClass("events", "query_encrypt", "eventsController", EventsController.class, EventsQueryRequest.class);

        addRequestClass("events", "list", "eventsController", EventsController.class, EventsQueryRequest.class);
        addRequestClass("events", "list_encrypt", "eventsController", EventsController.class, EventsQueryRequest.class);

        addRequestClass("events", "count", "eventsController", EventsController.class, EventsQueryRequest.class);
        addRequestClass("events", "count_encrypt", "eventsController", EventsController.class, EventsQueryRequest.class);

        addRequestClass("events", "stat", "eventsController", EventsController.class, EventsQueryRequest.class);
        addRequestClass("events", "stat_encrypt", "eventsController", EventsController.class, EventsQueryRequest.class);

    }

    @PostMapping("/add")
    public Integer addEvents(@MixRequestBody EventsAddRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("events", "add", request, callFromEncrypt);
        return super.addEvents(request);
    }

    @PostMapping("/add_encrypt")
    public String addEventsEncrypt(@MixRequestBody String strRequest) throws Exception {
        EventsAddRequest request = (EventsAddRequest) super.decrypt("events", "add_encrypt", strRequest, EventsAddRequest.class);
        Integer result = addEvents(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/update")
    public Integer updateEvents(@MixRequestBody EventsUpdateRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("events", "update", request, callFromEncrypt);
        return super.updateEvents(request);
    }

    @PostMapping("/update_encrypt")
    public String updateEventsEncrypt(@MixRequestBody String strRequest) throws Exception {
        EventsUpdateRequest request = (EventsUpdateRequest) super.decrypt("events", "update_encrypt", strRequest, EventsUpdateRequest.class);
        Integer result = updateEvents(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/delete")
    public Integer deleteEvents(@MixRequestBody EventsDeleteRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("events", "delete", request, callFromEncrypt);
        return super.deleteEvents(request);
    }

    @PostMapping("/delete_encrypt")
    public String deleteEventsEncrypt(@MixRequestBody String strRequest) throws Exception {
        EventsDeleteRequest request = (EventsDeleteRequest) super.decrypt("events", "delete_encrypt", strRequest, EventsDeleteRequest.class);
        Integer result = deleteEvents(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/query")
    public EventsQueryResponse queryEvents(@MixRequestBody EventsQueryRequest request, Integer callFromEncrypt) throws Exception {
      super.fixRequest("events", "query", request, callFromEncrypt);
      return super.queryEvents(request);
    }

    @PostMapping("/query_encrypt")
    public String queryEventsEncrypt(@MixRequestBody String strRequest) throws Exception {
        EventsQueryRequest request = (EventsQueryRequest) super.decrypt("events", "query_encrypt", strRequest, EventsQueryRequest.class);
        EventsQueryResponse result = queryEvents(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/list")
    public List<EventsQueryResponse> listEvents(@MixRequestBody EventsQueryRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("events", "list", request, callFromEncrypt);
        if (super.needTotal("events", "list", request)) {
            super.setTotal("events", "list", request, super.countEvents(request));
        }
        return super.listEvents(request);
    }

    @PostMapping("/list_encrypt")
    public String listEventsEncrypt(@MixRequestBody String strRequest) throws Exception {
        EventsQueryRequest request = (EventsQueryRequest) super.decrypt("events", "list_encrypt", strRequest, EventsQueryRequest.class);
        List<EventsQueryResponse> result = listEvents(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/count")
    public Integer countEvents(@MixRequestBody EventsQueryRequest request, Integer callFromEncrypt) throws Exception {
      super.fixRequest("events", "count", request, callFromEncrypt);
      return super.countEvents(request);
    }


    @PostMapping("/count_encrypt")
    public String countEventsEncrypt(@MixRequestBody String strRequest) throws Exception {
        EventsQueryRequest request = (EventsQueryRequest) super.decrypt("events", "count_encrypt", strRequest, EventsQueryRequest.class);
        Integer result = countEvents(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/stat")
    public BaseStatResponse statEvents(@MixRequestBody EventsQueryRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("events", "stat", request, callFromEncrypt);
        return super.statEvents(request);
    }

    @PostMapping("/stat_encrypt")
    public String statEventsEncrypt(@MixRequestBody String strRequest) throws Exception {
        EventsQueryRequest request = (EventsQueryRequest) super.decrypt("events", "stat_encrypt", strRequest, EventsQueryRequest.class);
        BaseStatResponse result = statEvents(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    static {
        addRequestClass("events", "events", "eventsController", EventsController.class, EventsForEventsRequest.class);
        addRequestClass("events", "events_encrypt", "eventsController", EventsController.class, EventsForEventsRequest.class);
    
        addRequestClass("events", "count_events", "eventsController", EventsController.class, EventsForEventsRequest.class);
        addRequestClass("events", "count_events_encrypt", "eventsController", EventsController.class, EventsForEventsRequest.class);
    
        addRequestClass("events", "stat_events", "eventsController", EventsController.class, EventsForEventsRequest.class);
        addRequestClass("events", "stat_events_encrypt", "eventsController", EventsController.class, EventsForEventsRequest.class);
    
        addRequestClass("events", "export_excel_events", "eventsController", EventsController.class, EventsForEventsRequest.class);
        addRequestClass("events", "export_excel_events_encrypt", "eventsController", EventsController.class, EventsForEventsRequest.class);
    }

    @PostMapping("/events")
    public List<EventsForEventsResponse> events(@MixRequestBody EventsForEventsRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("events", "events", request, callFromEncrypt);
        if (super.needTotal("events", "events", request)) {
            super.setTotal("events", "events", request, super.countForEvents(request));
        }
        return super.events(request);
    }

    @PostMapping("/events_encrypt")
    public String eventsEncrypt(@MixRequestBody String strRequest) throws Exception {
        EventsForEventsRequest request = (EventsForEventsRequest)decrypt("events", "events_encrypt", strRequest, EventsForEventsRequest.class);
        List<EventsForEventsResponse> result = events(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);
        
        return super.encrypt(request, response);
    }

    @PostMapping("/count_events")
    public Integer countForEvents(@MixRequestBody EventsForEventsRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("events", "count_events", request, callFromEncrypt);
        return super.countForEvents(request);
    }

    @PostMapping("/count_events_encrypt")
    public String countForEventsEncrypt(@MixRequestBody String strRequest) throws Exception {
        EventsForEventsRequest request = (EventsForEventsRequest)decrypt("events", "count_for_events_encrypt", strRequest, EventsForEventsRequest.class);
        Integer result = countForEvents(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);
        
        return super.encrypt(request, response);
    }

    @PostMapping("/stat_events")
    public BaseStatResponse statForEvents(@MixRequestBody EventsForEventsRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("events", "stat_events", request, callFromEncrypt);
        return super.statForEvents(request);
    }

    @PostMapping("/stat_events_encrypt")
    public String statForEventsEncrypt(@MixRequestBody String strRequest) throws Exception {
        EventsForEventsRequest request = (EventsForEventsRequest)decrypt("events", "stat_for_events_encrypt", strRequest, EventsForEventsRequest.class);
        BaseStatResponse result = statForEvents(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);
        
        return super.encrypt(request, response);
    }

    @ResponseBody
    @PostMapping("/export_excel_events")
    public String exportExcelEvents(@MixRequestBody EventsForEventsRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("events", "export_excel_events", request, callFromEncrypt);
        return super.exportExcelEvents(request);
    }

    @ResponseBody
    @PostMapping("/export_excel_events_encrypt")
    public String exportExcelEventsEncrypt(@MixRequestBody String strRequest) throws Exception {
        EventsForEventsRequest request = (EventsForEventsRequest)decrypt("events", "export_excel_events_encrypt", strRequest, EventsForEventsRequest.class);
        String result = exportExcelEvents(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);
        
        return super.encrypt(request, response);
    }

    static {
        addRequestClass("events", "events_member", "eventsController", EventsController.class, EventsForEventsMemberRequest.class);
        addRequestClass("events", "events_member_encrypt", "eventsController", EventsController.class, EventsForEventsMemberRequest.class);
    
        addRequestClass("events", "count_events_member", "eventsController", EventsController.class, EventsForEventsMemberRequest.class);
        addRequestClass("events", "count_events_member_encrypt", "eventsController", EventsController.class, EventsForEventsMemberRequest.class);
    
        addRequestClass("events", "stat_events_member", "eventsController", EventsController.class, EventsForEventsMemberRequest.class);
        addRequestClass("events", "stat_events_member_encrypt", "eventsController", EventsController.class, EventsForEventsMemberRequest.class);
    
        addRequestClass("events", "export_excel_events_member", "eventsController", EventsController.class, EventsForEventsMemberRequest.class);
        addRequestClass("events", "export_excel_events_member_encrypt", "eventsController", EventsController.class, EventsForEventsMemberRequest.class);
    }

    @PostMapping("/events_member")
    public List<EventsForEventsMemberResponse> eventsMember(@MixRequestBody EventsForEventsMemberRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("events", "events_member", request, callFromEncrypt);
        if (super.needTotal("events", "events_member", request)) {
            super.setTotal("events", "events_member", request, super.countForEventsMember(request));
        }
        return super.eventsMember(request);
    }

    @PostMapping("/events_member_encrypt")
    public String eventsMemberEncrypt(@MixRequestBody String strRequest) throws Exception {
        EventsForEventsMemberRequest request = (EventsForEventsMemberRequest)decrypt("events", "events_member_encrypt", strRequest, EventsForEventsMemberRequest.class);
        List<EventsForEventsMemberResponse> result = eventsMember(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);
        
        return super.encrypt(request, response);
    }

    @PostMapping("/count_events_member")
    public Integer countForEventsMember(@MixRequestBody EventsForEventsMemberRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("events", "count_events_member", request, callFromEncrypt);
        return super.countForEventsMember(request);
    }

    @PostMapping("/count_events_member_encrypt")
    public String countForEventsMemberEncrypt(@MixRequestBody String strRequest) throws Exception {
        EventsForEventsMemberRequest request = (EventsForEventsMemberRequest)decrypt("events", "count_for_events_member_encrypt", strRequest, EventsForEventsMemberRequest.class);
        Integer result = countForEventsMember(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);
        
        return super.encrypt(request, response);
    }

    @PostMapping("/stat_events_member")
    public BaseStatResponse statForEventsMember(@MixRequestBody EventsForEventsMemberRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("events", "stat_events_member", request, callFromEncrypt);
        return super.statForEventsMember(request);
    }

    @PostMapping("/stat_events_member_encrypt")
    public String statForEventsMemberEncrypt(@MixRequestBody String strRequest) throws Exception {
        EventsForEventsMemberRequest request = (EventsForEventsMemberRequest)decrypt("events", "stat_for_events_member_encrypt", strRequest, EventsForEventsMemberRequest.class);
        BaseStatResponse result = statForEventsMember(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);
        
        return super.encrypt(request, response);
    }

    @ResponseBody
    @PostMapping("/export_excel_events_member")
    public String exportExcelEventsMember(@MixRequestBody EventsForEventsMemberRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("events", "export_excel_events_member", request, callFromEncrypt);
        return super.exportExcelEventsMember(request);
    }

    @ResponseBody
    @PostMapping("/export_excel_events_member_encrypt")
    public String exportExcelEventsMemberEncrypt(@MixRequestBody String strRequest) throws Exception {
        EventsForEventsMemberRequest request = (EventsForEventsMemberRequest)decrypt("events", "export_excel_events_member_encrypt", strRequest, EventsForEventsMemberRequest.class);
        String result = exportExcelEventsMember(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);
        
        return super.encrypt(request, response);
    }


}
